package com.hxy.controller;

import com.github.pagehelper.PageInfo;
import com.hxy.common.JsonResult;
import com.hxy.pojo.*;
import com.hxy.pojo.vo.BranchVo;
import com.hxy.service.StaticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author feiyu
 * 静态表控制类
 * folk(民族表)/estatus(工作状态表)/学历表(kultur)/visage(党派表)/business(岗位表)/
 */
@Controller
@RequestMapping("/static")
public class StaticController {
    @Autowired
    private StaticService staticService;

    /**
     * 1.folk(民族表)
     *
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping("/folk/pagelist")
    @ResponseBody
    public JsonResult showFolkAll(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                  @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
        page = page == null ? 1 : page;
        PageInfo<Folk> folkPageInfo = staticService.selectAllFolk(page, limit);
        return new JsonResult(1, "msg", folkPageInfo);
    }

    /**
     * 2.estatus(工作状态表)
     *
     * @return
     */
    @RequestMapping("/estatus/list")
    @ResponseBody
    public JsonResult showEstatus(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                  @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
        page = page == null ? 1 : page;
        PageInfo<Estatus> estatuses = staticService.selectEstatusAll(page, limit);
        return new JsonResult(0, "success", estatuses);
    }

    /**
     * 3.business(职位表)
     *
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping("/business/show")
    @ResponseBody
    public JsonResult showBusiness(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                   @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
        page = page == null ? 1 : page;
        PageInfo<Business> businessPageInfo = staticService.selectAllPagerBusiness(page, limit);
        return new JsonResult(0, "success", businessPageInfo);
    }

    /**
     * 学历表
     *
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping("/kultur/show")
    @ResponseBody
    public JsonResult showKultur(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                 @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
        page = page == null ? 1 : page;
        PageInfo<Kultur> kulturPageInfo = staticService.selectAllPagerKultur(page, limit);
        return new JsonResult(0, "success", kulturPageInfo);

    }

    @RequestMapping("/visage/show")
    @ResponseBody
    public JsonResult showVisage(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                 @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
        page = page == null ? 1 : page;
        PageInfo<Visage> visagePageInfo = staticService.selectAllPagerVisage(page, limit);
        return new JsonResult(0, "success", visagePageInfo);

    }

}
